package com.learn.spring.ioc.core;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 自己的容器
 */
public class IOCContext {
    /* 使用饿汉式 */
    public static final IOCContext INSTANCE = new IOCContext();

    public static IOCContext getInstance() {
        return INSTANCE;
    }

    private Map beans = new ConcurrentHashMap<Class<?>, Object>();

    public Object getBean(Class<?> clazz) {
        return beans.get(clazz);
    }

    public void registerBean(Class<?> clazz, Object bean) {
        this.beans.put(clazz, bean);
    }
}
